﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ViecLamService;
using System.ServiceModel;

namespace HostViecLam
{
    class Program
    {
        static void HostingViecLam(ServiceHost hostViecLam)
        {
            if (hostViecLam == null)
                return;

            hostViecLam.Open();

            Console.WriteLine("Service is running in following address:");

            foreach (var endpoint in hostViecLam.Description.Endpoints)
                Console.WriteLine("- {0}", endpoint.Address);
        }

        static void Main(string[] args)
        {
            try
            {
                ServiceHost hostViecLam = new ServiceHost(typeof(ViecLamService.Service1));
                HostingViecLam(hostViecLam);

                Console.WriteLine();
                Console.WriteLine("Press enter to shutdown the host.");
                Console.ReadLine();

                hostViecLam.Close();
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
    }
}
